<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
  <script>
    //es5 定义类
    // function Person(name, age) {
    //   this.name = name;
    //   this.age = age;
    // }

    // Person.prototype.running = function() {
    //   console.log(this.name, this.age, "running");
    // }

    // var p = new Person('yzh', 18)
    // console.log(p, p.name);

    // p.running()

    //es6
    class Person {
      //构造方法
      constructor(name, age) {
        this.name = name
        this.age = age
      }

      running() {
        console.log("running");
      }

    }
    
    const p = new Person("yzh", 18)
    console.log(p, p.name);

    p.running()
  </script>
</body>
</html>